package app.caihan.wanandroid.model.db

import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
import app.caihan.wanandroid.model.bean.BannerBean
import app.caihan.wanandroid.model.bean.Chapters
import app.caihan.wanandroid.model.bean.User
import app.caihan.wanandroid.model.db.migration.MIGRATION
import com.blankj.utilcode.util.Utils

/**
 *
 *
 * @author Seven-C
 * @date 2020/8/20
 */
@Database(
    entities = [BannerBean::class, Chapters::class, User::class],
    version = 1,
    exportSchema = false
)
abstract class WanDatabase : RoomDatabase() {

    abstract fun locaData(): WanDao


    companion object {
        fun getInstanse() = SingletonHolder.INSTANCE
    }

    private object SingletonHolder {
        val INSTANCE = Room
            .databaseBuilder(Utils.getApp(),WanDatabase::class.java,"sc_wan_db")
            .addMigrations(MIGRATION.MIGRATION_1_2)
            .build()
    }
}